package game;

import javax.swing.*;

public class Images {
    //公开的，静态的，图片类型，变量名
    public static ImageIcon sea;//海洋图片
    public static ImageIcon battleship;//战舰图片
    public static ImageIcon bomb;//炸弹图片
    public static ImageIcon gameover;//游戏结束
    public static ImageIcon mine;//水雷图片
    public static ImageIcon minesubm;//水雷潜艇
    public static ImageIcon obsersubm;//侦查潜艇
    public static ImageIcon torpesubm;//鱼雷潜艇

    static {//初始话静态图片
        //将img中sea.png读取到静态变量sea中
        sea=new ImageIcon("img/sea.png");
        battleship=new ImageIcon("img/battleship.png");
        bomb=new ImageIcon("img/bomb.png");
        gameover=new ImageIcon("img/gameover.png");
        mine=new ImageIcon("img/mine.png");
        minesubm=new ImageIcon("img/minesubm.png");
        obsersubm=new ImageIcon("img/obsersubm.png");
        torpesubm=new ImageIcon("img/torpesubm.png");
    }

    public static void main(String[] args) {//测试图片是否读取成功
        //返回8表示图片读取成功，返回其余数字表示读取失败
        System.out.println(sea.getImageLoadStatus());//8
        System.out.println(battleship.getImageLoadStatus());//8
        System.out.println(bomb.getImageLoadStatus());//8
        System.out.println(gameover.getImageLoadStatus());//8
        System.out.println(mine.getImageLoadStatus());//8
        System.out.println(minesubm.getImageLoadStatus());//8
        System.out.println(obsersubm.getImageLoadStatus());//8
        System.out.println(torpesubm.getImageLoadStatus());//8
    }
}
